<?php
/**
 * Created by PhpStorm.
 * User: 钊鑫
 * Date: 2019/1/23
 * Time: 10:05
 */
namespace app\api\validate;

use app\api\model\Homeuser as HomeuserModel;

class Login extends Base
{
    protected $rule = [
        'username'      =>  'require|checkname',
        'password'      =>  'require',
        'xcxcode'       =>  'require|isNotEmpty'
    ];
    protected $message  =   [
        'username.require'          =>  '用户名不能为空！',
        'password.require'          =>  '密码不能为空！',
        'username.checkname'        =>  '该用户名不存在！',
        'xcxcode.require'           =>  '没有xcxcode不能获取Token'
    ];

    protected function checkname($value){
        $result = HomeuserModel::where(['username'=>$value])->count();
        return ($result <= 0) ? false : true;
    }
}